package cn.com.sparkle.global.configserver.server;

import java.util.concurrent.ConcurrentHashMap;

import org.apache.log4j.Logger;

import cn.com.sparkle.global.configserver.message.ProtobufMessages.Value;
import cn.com.sparkle.paxos.ClassicPaxosServer;

public class ConfigServer {
	public static void start(String path) throws NumberFormatException,
			Exception {
		ConcurrentHashMap<String, Value> map = new ConcurrentHashMap<String, Value>(
				10000);
		Repository repository = new Repository(path);
		long instanceId = repository.initMemory(map);

		ClassicPaxosServer ps = new ClassicPaxosServer(instanceId + 1);
		ps.init(path, new ConfigServerHandler(map, path));
	}

	public static void main(String[] args) {
		if (args.length == 0) {
			System.out.println("you need a dir of configuration!");
		}
	}
}
